.class Lcom/nemustech/regina/UpdaterTask;
.super Landroid/os/AsyncTask;
.source "UpdaterTask.java"


# annotations
.annotation system Ldalvik/annotation/Signature;
    value = {
        "Landroid/os/AsyncTask",
        "<",
        "Ljava/lang/Void;",
        "Ljava/lang/Integer;",
        "Ljava/lang/Void;",
        ">;"
    }
.end annotation


# static fields
.field public static PACKAGE_INSTALLATION:I = 0x0

.field private static final TAG:Ljava/lang/String; = "UpdaterTask"

.field private static final filePath:Ljava/lang/String;


# instance fields
.field private dialog:Landroid/app/ProgressDialog;

.field private isLog:Z

.field private parent:Landroid/app/Activity;

.field private updateList:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Lcom/nemustech/regina/XMLRecord;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .locals 2

    .prologue
    .line 27
    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v1

    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string v1, "/Android/data/com.nemustech.regina/"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/nemustech/regina/UpdaterTask;->filePath:Ljava/lang/String;

    .line 28
    const/4 v0, 0x0

    sput v0, Lcom/nemustech/regina/UpdaterTask;->PACKAGE_INSTALLATION:I

    return-void
.end method

.method public constructor <init>(Ljava/util/ArrayList;Landroid/app/Activity;)V
    .locals 11
    .parameter
    .parameter "parent"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/nemustech/regina/XMLRecord;",
            ">;",
            "Landroid/app/Activity;",
            ")V"
        }
    .end annotation

    .prologue
    .local p1, updateList:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/nemustech/regina/XMLRecord;>;"
    const/4 v9, 0x1

    .line 34
    invoke-direct {p0}, Landroid/os/AsyncTask;-><init>()V

    .line 32
    iput-boolean v9, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    .line 36
    iput-object p1, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    .line 37
    iput-object p2, p0, Lcom/nemustech/regina/UpdaterTask;->parent:Landroid/app/Activity;

    .line 39
    const/4 v4, 0x0

    .line 40
    .local v4, max:I
    const/4 v2, 0x0

    .local v2, i:I
    :goto_0
    iget-object v7, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    invoke-virtual {v7}, Ljava/util/ArrayList;->size()I

    move-result v7

    if-ge v2, v7, :cond_1

    .line 41
    invoke-virtual {p1, v2}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Lcom/nemustech/regina/XMLRecord;

    .line 43
    .local v5, record:Lcom/nemustech/regina/XMLRecord;
    :try_start_0
    new-instance v6, Ljava/net/URL;

    invoke-virtual {v5}, Lcom/nemustech/regina/XMLRecord;->getUrl()Ljava/lang/String;

    move-result-object v7

    invoke-direct {v6, v7}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    .line 44
    .local v6, url:Ljava/net/URL;
    invoke-virtual {v6}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;

    move-result-object v0

    .line 45
    .local v0, conn:Ljava/net/URLConnection;
    invoke-virtual {v0}, Ljava/net/URLConnection;->getContentLength()I

    move-result v3

    .line 46
    .local v3, length:I
    if-lez v3, :cond_0

    .line 47
    add-int/2addr v4, v3

    .line 40
    .end local v0           #conn:Ljava/net/URLConnection;
    .end local v3           #length:I
    .end local v6           #url:Ljava/net/URL;
    :goto_1
    add-int/lit8 v2, v2, 0x1

    goto :goto_0

    .line 51
    .restart local v0       #conn:Ljava/net/URLConnection;
    .restart local v3       #length:I
    .restart local v6       #url:Ljava/net/URL;
    :cond_0
    invoke-virtual {p1}, Ljava/util/ArrayList;->clear()V
    :try_end_0
    .catch Ljava/net/MalformedURLException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1

    goto :goto_1

    .line 53
    .end local v0           #conn:Ljava/net/URLConnection;
    .end local v3           #length:I
    .end local v6           #url:Ljava/net/URL;
    :catch_0
    move-exception v7

    move-object v1, v7

    .line 56
    .local v1, e:Ljava/net/MalformedURLException;
    invoke-virtual {v1}, Ljava/net/MalformedURLException;->printStackTrace()V

    goto :goto_1

    .line 57
    .end local v1           #e:Ljava/net/MalformedURLException;
    :catch_1
    move-exception v7

    move-object v1, v7

    .line 61
    .local v1, e:Ljava/io/IOException;
    invoke-virtual {p1}, Ljava/util/ArrayList;->clear()V

    .line 62
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_1

    .line 66
    .end local v1           #e:Ljava/io/IOException;
    .end local v5           #record:Lcom/nemustech/regina/XMLRecord;
    :cond_1
    iget-object v7, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    invoke-virtual {v7}, Ljava/util/ArrayList;->isEmpty()Z

    move-result v7

    if-eqz v7, :cond_2

    .line 67
    const-string v7, "UpdaterTask"

    const-string v8, "Failed to connect to server"

    iget-boolean v9, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v7, v8, v9}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 87
    :goto_2
    return-void

    .line 70
    :cond_2
    new-instance v7, Landroid/app/ProgressDialog;

    invoke-direct {v7, p2}, Landroid/app/ProgressDialog;-><init>(Landroid/content/Context;)V

    iput-object v7, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    .line 71
    iget-object v7, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    const-string v8, "Regina Updater"

    invoke-virtual {v7, v8}, Landroid/app/ProgressDialog;->setTitle(Ljava/lang/CharSequence;)V

    .line 72
    iget-object v7, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    const v8, 0x7f070061

    invoke-virtual {p2, v8}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v7, v8}, Landroid/app/ProgressDialog;->setMessage(Ljava/lang/CharSequence;)V

    .line 73
    iget-object v7, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    const/4 v8, 0x0

    invoke-virtual {v7, v8}, Landroid/app/ProgressDialog;->setProgress(I)V

    .line 74
    iget-object v7, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    invoke-virtual {v7, v4}, Landroid/app/ProgressDialog;->setMax(I)V

    .line 75
    iget-object v7, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    invoke-virtual {v7, v9}, Landroid/app/ProgressDialog;->setProgressStyle(I)V

    .line 76
    iget-object v7, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    invoke-virtual {v7, v9}, Landroid/app/ProgressDialog;->setCancelable(Z)V

    .line 77
    iget-object v7, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    const/4 v8, -0x2

    const v9, 0x7f070060

    invoke-virtual {p2, v9}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v9

    new-instance v10, Lcom/nemustech/regina/UpdaterTask$1;

    invoke-direct {v10, p0}, Lcom/nemustech/regina/UpdaterTask$1;-><init>(Lcom/nemustech/regina/UpdaterTask;)V

    invoke-virtual {v7, v8, v9, v10}, Landroid/app/ProgressDialog;->setButton(ILjava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)V

    .line 84
    iget-object v7, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    invoke-virtual {v7}, Landroid/app/ProgressDialog;->show()V

    .line 85
    const-string v7, "UpdaterTask"

    const-string v8, "ProgressDialog created"

    iget-boolean v9, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v7, v8, v9}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    goto :goto_2
.end method


# virtual methods
.method protected bridge synthetic doInBackground([Ljava/lang/Object;)Ljava/lang/Object;
    .locals 1
    .parameter "x0"

    .prologue
    .line 25
    check-cast p1, [Ljava/lang/Void;

    .end local p1
    invoke-virtual {p0, p1}, Lcom/nemustech/regina/UpdaterTask;->doInBackground([Ljava/lang/Void;)Ljava/lang/Void;

    move-result-object v0

    return-object v0
.end method

.method protected varargs doInBackground([Ljava/lang/Void;)Ljava/lang/Void;
    .locals 12
    .parameter "params"

    .prologue
    .line 98
    const-string v9, "UpdaterTask"

    const-string v10, "Downloading started"

    iget-boolean v11, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v9, v10, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 99
    const/4 v2, 0x0

    .local v2, i:I
    :goto_0
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    invoke-virtual {v9}, Ljava/util/ArrayList;->size()I

    move-result v9

    if-ge v2, v9, :cond_1

    .line 100
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    invoke-virtual {v9, v2}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v6

    check-cast v6, Lcom/nemustech/regina/XMLRecord;

    .line 103
    .local v6, record:Lcom/nemustech/regina/XMLRecord;
    :try_start_0
    new-instance v7, Ljava/net/URL;

    invoke-virtual {v6}, Lcom/nemustech/regina/XMLRecord;->getUrl()Ljava/lang/String;

    move-result-object v9

    invoke-direct {v7, v9}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    .line 104
    .local v7, u:Ljava/net/URL;
    invoke-virtual {v7}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;

    move-result-object v8

    .line 105
    .local v8, uc:Ljava/net/URLConnection;
    const/4 v9, 0x1

    invoke-virtual {v8, v9}, Ljava/net/URLConnection;->setDoInput(Z)V

    .line 106
    invoke-virtual {v8}, Ljava/net/URLConnection;->getInputStream()Ljava/io/InputStream;

    move-result-object v3

    .line 109
    .local v3, in:Ljava/io/InputStream;
    new-instance v5, Ljava/io/FileOutputStream;

    new-instance v9, Ljava/lang/StringBuilder;

    invoke-direct {v9}, Ljava/lang/StringBuilder;-><init>()V

    sget-object v10, Lcom/nemustech/regina/UpdaterTask;->filePath:Ljava/lang/String;

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v6}, Lcom/nemustech/regina/XMLRecord;->getAppName()Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    const-string v10, "_"

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v6}, Lcom/nemustech/regina/XMLRecord;->getServerVersionName()Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    const-string v10, ".apk"

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-direct {v5, v9}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;)V

    .line 110
    .local v5, out:Ljava/io/OutputStream;
    const/16 v9, 0x400

    new-array v0, v9, [B

    .line 117
    .local v0, buf:[B
    const/16 v9, 0xbb8

    invoke-virtual {v8, v9}, Ljava/net/URLConnection;->setReadTimeout(I)V

    .line 118
    const-string v9, "UpdaterTask"

    new-instance v10, Ljava/lang/StringBuilder;

    invoke-direct {v10}, Ljava/lang/StringBuilder;-><init>()V

    const-string v11, "Read Time Out Limit : "

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v8}, Ljava/net/URLConnection;->getReadTimeout()I

    move-result v11

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v10

    const-string v11, "ms"

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v10

    iget-boolean v11, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v9, v10, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 120
    :goto_1
    invoke-virtual {v3, v0}, Ljava/io/InputStream;->read([B)I

    move-result v4

    .local v4, len:I
    if-lez v4, :cond_0

    .line 121
    const/4 v9, 0x0

    invoke-virtual {v5, v0, v9, v4}, Ljava/io/OutputStream;->write([BII)V

    .line 122
    const/4 v9, 0x1

    new-array v9, v9, [Ljava/lang/Integer;

    const/4 v10, 0x0

    invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v11

    aput-object v11, v9, v10

    invoke-virtual {p0, v9}, Lcom/nemustech/regina/UpdaterTask;->publishProgress([Ljava/lang/Object;)V
    :try_end_0
    .catch Ljava/net/MalformedURLException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1

    goto :goto_1

    .line 127
    .end local v0           #buf:[B
    .end local v3           #in:Ljava/io/InputStream;
    .end local v4           #len:I
    .end local v5           #out:Ljava/io/OutputStream;
    .end local v7           #u:Ljava/net/URL;
    .end local v8           #uc:Ljava/net/URLConnection;
    :catch_0
    move-exception v9

    move-object v1, v9

    .line 130
    .local v1, e:Ljava/net/MalformedURLException;
    invoke-virtual {v1}, Ljava/net/MalformedURLException;->printStackTrace()V

    .line 99
    .end local v1           #e:Ljava/net/MalformedURLException;
    :goto_2
    add-int/lit8 v2, v2, 0x1

    goto/16 :goto_0

    .line 125
    .restart local v0       #buf:[B
    .restart local v3       #in:Ljava/io/InputStream;
    .restart local v4       #len:I
    .restart local v5       #out:Ljava/io/OutputStream;
    .restart local v7       #u:Ljava/net/URL;
    .restart local v8       #uc:Ljava/net/URLConnection;
    :cond_0
    :try_start_1
    invoke-virtual {v5}, Ljava/io/OutputStream;->close()V

    .line 126
    invoke-virtual {v3}, Ljava/io/InputStream;->close()V
    :try_end_1
    .catch Ljava/net/MalformedURLException; {:try_start_1 .. :try_end_1} :catch_0
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_1

    goto :goto_2

    .line 131
    .end local v0           #buf:[B
    .end local v3           #in:Ljava/io/InputStream;
    .end local v4           #len:I
    .end local v5           #out:Ljava/io/OutputStream;
    .end local v7           #u:Ljava/net/URL;
    .end local v8           #uc:Ljava/net/URLConnection;
    :catch_1
    move-exception v9

    move-object v1, v9

    .line 135
    .local v1, e:Ljava/io/IOException;
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    invoke-virtual {v9}, Ljava/util/ArrayList;->clear()V

    .line 136
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_2

    .line 139
    .end local v1           #e:Ljava/io/IOException;
    .end local v6           #record:Lcom/nemustech/regina/XMLRecord;
    :cond_1
    const/4 v9, 0x0

    return-object v9
.end method

.method protected onCancelled()V
    .locals 4

    .prologue
    .line 145
    const-string v1, "ReginaUpdater"

    const-string v2, "Downloading canceled"

    iget-boolean v3, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v1, v2, v3}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 146
    iget-object v1, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    if-eqz v1, :cond_0

    .line 147
    iget-object v1, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    invoke-virtual {v1}, Landroid/app/ProgressDialog;->dismiss()V

    .line 150
    :cond_0
    iget-object v1, p0, Lcom/nemustech/regina/UpdaterTask;->parent:Landroid/app/Activity;

    invoke-virtual {v1}, Landroid/app/Activity;->getApplicationContext()Landroid/content/Context;

    move-result-object v1

    iget-object v2, p0, Lcom/nemustech/regina/UpdaterTask;->parent:Landroid/app/Activity;

    const v3, 0x7f070071

    invoke-virtual {v2, v3}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Lcom/nemustech/regina/RUtils;->showToast(Landroid/content/Context;Ljava/lang/String;)Landroid/widget/Toast;

    .line 152
    new-instance v0, Landroid/content/Intent;

    const-string v1, "ACTION_REGINA_UPDATER_CANCEL"

    invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 153
    .local v0, intent:Landroid/content/Intent;
    iget-object v1, p0, Lcom/nemustech/regina/UpdaterTask;->parent:Landroid/app/Activity;

    invoke-virtual {v1, v0}, Landroid/app/Activity;->sendBroadcast(Landroid/content/Intent;)V

    .line 154
    invoke-super {p0}, Landroid/os/AsyncTask;->onCancelled()V

    .line 155
    return-void
.end method

.method protected bridge synthetic onPostExecute(Ljava/lang/Object;)V
    .locals 0
    .parameter "x0"

    .prologue
    .line 25
    check-cast p1, Ljava/lang/Void;

    .end local p1
    invoke-virtual {p0, p1}, Lcom/nemustech/regina/UpdaterTask;->onPostExecute(Ljava/lang/Void;)V

    return-void
.end method

.method protected onPostExecute(Ljava/lang/Void;)V
    .locals 12
    .parameter "result"

    .prologue
    .line 160
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    if-eqz v9, :cond_0

    .line 161
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    invoke-virtual {v9}, Landroid/app/ProgressDialog;->dismiss()V

    .line 163
    :cond_0
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    invoke-virtual {v9}, Ljava/util/ArrayList;->isEmpty()Z

    move-result v9

    if-eqz v9, :cond_1

    .line 164
    const-string v9, "UpdaterTask"

    const-string v10, "Failed to download"

    iget-boolean v11, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v9, v10, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 165
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->parent:Landroid/app/Activity;

    invoke-virtual {v9}, Landroid/app/Activity;->getApplicationContext()Landroid/content/Context;

    move-result-object v9

    iget-object v10, p0, Lcom/nemustech/regina/UpdaterTask;->parent:Landroid/app/Activity;

    const v11, 0x7f070072

    invoke-virtual {v10, v11}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v10

    invoke-static {v9, v10}, Lcom/nemustech/regina/RUtils;->showToast(Landroid/content/Context;Ljava/lang/String;)Landroid/widget/Toast;

    .line 217
    :goto_0
    invoke-super {p0, p1}, Landroid/os/AsyncTask;->onPostExecute(Ljava/lang/Object;)V

    .line 218
    return-void

    .line 168
    :cond_1
    const-string v9, "UpdaterTask"

    const-string v10, "Success to download"

    iget-boolean v11, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v9, v10, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 171
    const/4 v2, 0x0

    .local v2, i:I
    :goto_1
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    invoke-virtual {v9}, Ljava/util/ArrayList;->size()I

    move-result v9

    if-ge v2, v9, :cond_4

    .line 172
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    invoke-virtual {v9, v2}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v6

    check-cast v6, Lcom/nemustech/regina/XMLRecord;

    .line 173
    .local v6, record:Lcom/nemustech/regina/XMLRecord;
    invoke-virtual {v6}, Lcom/nemustech/regina/XMLRecord;->getAppName()Ljava/lang/String;

    move-result-object v0

    .line 174
    .local v0, appName:Ljava/lang/String;
    invoke-virtual {v6}, Lcom/nemustech/regina/XMLRecord;->getServerVersionName()Ljava/lang/String;

    move-result-object v8

    .line 176
    .local v8, version:Ljava/lang/String;
    new-instance v1, Ljava/io/File;

    sget-object v9, Lcom/nemustech/regina/UpdaterTask;->filePath:Ljava/lang/String;

    invoke-direct {v1, v9}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 177
    .local v1, file:Ljava/io/File;
    new-instance v9, Lcom/nemustech/regina/UpdaterTask$2;

    invoke-direct {v9, p0, v0, v8}, Lcom/nemustech/regina/UpdaterTask$2;-><init>(Lcom/nemustech/regina/UpdaterTask;Ljava/lang/String;Ljava/lang/String;)V

    invoke-virtual {v1, v9}, Ljava/io/File;->listFiles(Ljava/io/FilenameFilter;)[Ljava/io/File;

    move-result-object v5

    .line 185
    .local v5, list:[Ljava/io/File;
    if-eqz v5, :cond_2

    .line 186
    const/4 v4, 0x0

    .local v4, j:I
    :goto_2
    array-length v9, v5

    if-ge v4, v9, :cond_2

    .line 187
    const-string v9, "UpdaterTask"

    new-instance v10, Ljava/lang/StringBuilder;

    invoke-direct {v10}, Ljava/lang/StringBuilder;-><init>()V

    const-string v11, "fileName : "

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    aget-object v11, v5, v4

    invoke-virtual {v11}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object v11

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    const-string v11, " j : "

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10, v4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v10

    const-string v11, " length : "

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    array-length v11, v5

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v10

    iget-boolean v11, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v9, v10, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 188
    aget-object v9, v5, v4

    invoke-virtual {v9}, Ljava/io/File;->delete()Z

    .line 186
    add-int/lit8 v4, v4, 0x1

    goto :goto_2

    .line 192
    .end local v4           #j:I
    :cond_2
    new-instance v1, Ljava/io/File;

    .end local v1           #file:Ljava/io/File;
    new-instance v9, Ljava/lang/StringBuilder;

    invoke-direct {v9}, Ljava/lang/StringBuilder;-><init>()V

    sget-object v10, Lcom/nemustech/regina/UpdaterTask;->filePath:Ljava/lang/String;

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    const-string v10, "_"

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    const-string v10, ".apk"

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-direct {v1, v9}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 195
    .restart local v1       #file:Ljava/io/File;
    invoke-virtual {v6}, Lcom/nemustech/regina/XMLRecord;->getResetList()Ljava/util/ArrayList;

    move-result-object v7

    .line 196
    .local v7, resetList:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Ljava/lang/String;>;"
    if-eqz v7, :cond_3

    .line 197
    const/4 v4, 0x0

    .restart local v4       #j:I
    :goto_3
    invoke-virtual {v7}, Ljava/util/ArrayList;->size()I

    move-result v9

    if-ge v4, v9, :cond_3

    .line 198
    new-instance v1, Ljava/io/File;

    .end local v1           #file:Ljava/io/File;
    new-instance v9, Ljava/lang/StringBuilder;

    invoke-direct {v9}, Ljava/lang/StringBuilder;-><init>()V

    sget-object v10, Lcom/nemustech/regina/UpdaterTask;->filePath:Ljava/lang/String;

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v7, v4}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v9

    check-cast v9, Ljava/lang/String;

    invoke-virtual {v10, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-direct {v1, v9}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 200
    .restart local v1       #file:Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->delete()Z

    .line 197
    add-int/lit8 v4, v4, 0x1

    goto :goto_3

    .line 171
    .end local v4           #j:I
    :cond_3
    add-int/lit8 v2, v2, 0x1

    goto/16 :goto_1

    .line 204
    .end local v0           #appName:Ljava/lang/String;
    .end local v1           #file:Ljava/io/File;
    .end local v5           #list:[Ljava/io/File;
    .end local v6           #record:Lcom/nemustech/regina/XMLRecord;
    .end local v7           #resetList:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Ljava/lang/String;>;"
    .end local v8           #version:Ljava/lang/String;
    :cond_4
    const-string v9, "UpdaterTask"

    const-string v10, "Old files deleted"

    iget-boolean v11, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v9, v10, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 207
    const/4 v2, 0x0

    :goto_4
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    invoke-virtual {v9}, Ljava/util/ArrayList;->size()I

    move-result v9

    if-ge v2, v9, :cond_5

    .line 208
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    invoke-virtual {v9, v2}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v6

    check-cast v6, Lcom/nemustech/regina/XMLRecord;

    .line 209
    .restart local v6       #record:Lcom/nemustech/regina/XMLRecord;
    new-instance v1, Ljava/io/File;

    new-instance v9, Ljava/lang/StringBuilder;

    invoke-direct {v9}, Ljava/lang/StringBuilder;-><init>()V

    sget-object v10, Lcom/nemustech/regina/UpdaterTask;->filePath:Ljava/lang/String;

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v6}, Lcom/nemustech/regina/XMLRecord;->getAppName()Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    const-string v10, "_"

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v6}, Lcom/nemustech/regina/XMLRecord;->getServerVersionName()Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    const-string v10, ".apk"

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-direct {v1, v9}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 210
    .restart local v1       #file:Ljava/io/File;
    new-instance v3, Landroid/content/Intent;

    const-string v9, "android.intent.action.VIEW"

    invoke-direct {v3, v9}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 211
    .local v3, intent:Landroid/content/Intent;
    invoke-static {v1}, Landroid/net/Uri;->fromFile(Ljava/io/File;)Landroid/net/Uri;

    move-result-object v9

    const-string v10, "application/vnd.android.package-archive"

    invoke-virtual {v3, v9, v10}, Landroid/content/Intent;->setDataAndType(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;

    .line 212
    iget-object v9, p0, Lcom/nemustech/regina/UpdaterTask;->parent:Landroid/app/Activity;

    sget v10, Lcom/nemustech/regina/UpdaterTask;->PACKAGE_INSTALLATION:I

    invoke-virtual {v9, v3, v10}, Landroid/app/Activity;->startActivityForResult(Landroid/content/Intent;I)V

    .line 207
    add-int/lit8 v2, v2, 0x1

    goto :goto_4

    .line 214
    .end local v1           #file:Ljava/io/File;
    .end local v3           #intent:Landroid/content/Intent;
    .end local v6           #record:Lcom/nemustech/regina/XMLRecord;
    :cond_5
    const-string v9, "UpdaterTask"

    const-string v10, "Installation started"

    iget-boolean v11, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v9, v10, v11}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    goto/16 :goto_0
.end method

.method protected onPreExecute()V
    .locals 4

    .prologue
    .line 223
    iget-object v1, p0, Lcom/nemustech/regina/UpdaterTask;->updateList:Ljava/util/ArrayList;

    invoke-virtual {v1}, Ljava/util/ArrayList;->isEmpty()Z

    move-result v1

    if-eqz v1, :cond_2

    .line 224
    iget-object v1, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    if-eqz v1, :cond_0

    .line 225
    iget-object v1, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    invoke-virtual {v1}, Landroid/app/ProgressDialog;->dismiss()V

    .line 227
    :cond_0
    const-string v1, "UpdaterTask"

    const-string v2, "Failed to download"

    iget-boolean v3, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v1, v2, v3}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    .line 228
    iget-object v1, p0, Lcom/nemustech/regina/UpdaterTask;->parent:Landroid/app/Activity;

    invoke-virtual {v1}, Landroid/app/Activity;->getApplicationContext()Landroid/content/Context;

    move-result-object v1

    iget-object v2, p0, Lcom/nemustech/regina/UpdaterTask;->parent:Landroid/app/Activity;

    const v3, 0x7f070072

    invoke-virtual {v2, v3}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Lcom/nemustech/regina/RUtils;->showToast(Landroid/content/Context;Ljava/lang/String;)Landroid/widget/Toast;

    .line 239
    :cond_1
    :goto_0
    invoke-super {p0}, Landroid/os/AsyncTask;->onPreExecute()V

    .line 240
    return-void

    .line 232
    :cond_2
    new-instance v0, Ljava/io/File;

    sget-object v1, Lcom/nemustech/regina/UpdaterTask;->filePath:Ljava/lang/String;

    invoke-direct {v0, v1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 233
    .local v0, file:Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->isDirectory()Z

    move-result v1

    if-nez v1, :cond_1

    .line 234
    invoke-virtual {v0}, Ljava/io/File;->mkdirs()Z

    move-result v1

    if-eqz v1, :cond_1

    .line 235
    const-string v1, "UpdaterTask"

    const-string v2, "Directory created"

    iget-boolean v3, p0, Lcom/nemustech/regina/UpdaterTask;->isLog:Z

    invoke-static {v1, v2, v3}, Lcom/nemustech/regina/RLog;->d(Ljava/lang/String;Ljava/lang/String;Z)I

    goto :goto_0
.end method

.method protected varargs onProgressUpdate([Ljava/lang/Integer;)V
    .locals 3
    .parameter "values"

    .prologue
    .line 246
    iget-object v0, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    if-eqz v0, :cond_0

    .line 247
    iget-object v0, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    iget-object v1, p0, Lcom/nemustech/regina/UpdaterTask;->dialog:Landroid/app/ProgressDialog;

    invoke-virtual {v1}, Landroid/app/ProgressDialog;->getProgress()I

    move-result v1

    const/4 v2, 0x0

    aget-object v2, p1, v2

    invoke-virtual {v2}, Ljava/lang/Integer;->intValue()I

    move-result v2

    add-int/2addr v1, v2

    invoke-virtual {v0, v1}, Landroid/app/ProgressDialog;->setProgress(I)V

    .line 249
    :cond_0
    invoke-super {p0, p1}, Landroid/os/AsyncTask;->onProgressUpdate([Ljava/lang/Object;)V

    .line 250
    return-void
.end method

.method protected bridge synthetic onProgressUpdate([Ljava/lang/Object;)V
    .locals 0
    .parameter "x0"

    .prologue
    .line 25
    check-cast p1, [Ljava/lang/Integer;

    .end local p1
    invoke-virtual {p0, p1}, Lcom/nemustech/regina/UpdaterTask;->onProgressUpdate([Ljava/lang/Integer;)V

    return-void
.end method
